package com.awccis.admin.controller;

import com.awccis.common.pool.DriverPool;
import com.awccis.common.utils.Constants;
import com.awccis.common.websocket.DriverWsServer;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: Administrator
 * @Date: 2018/4/21 on 15:13
 * @since: 1.0
 * @description: 消息推送接口
 **/
@Controller
@RequestMapping(value = "/message")
public class MessageController {
    
    /**
     * 消息推送
     *
     * @param hashMap {"driverNickName": 31}
     * @return map
     */
    @RequestMapping(value = "/sendMessage", produces = Constants.REQUEST_PRODUCES)
    public @ResponseBody
    Object deleteAdmin(@RequestBody HashMap hashMap) {
        System.out.println("消息推送：" + hashMap);
        Map<String, Object> map = new HashMap(2);
        boolean result;
        String nickName = "driverNickName";
        if (hashMap.get(nickName) != null) {
            int driverNickName = Integer.parseInt(hashMap.get(nickName).toString());
            result = DriverPool.sendMessageByNickName(driverNickName, "sendMessage!");
            map.put(Constants.MAP_KEY_RESULT, result);
        }
        return map;
    }
    
}
